﻿using System;
using UnityEditor;
using UnityEngine;

[CustomPropertyDrawer(typeof(ReadOnlyAttribute))]
public class ReadOnlyAttributeDrawer : PropertyDrawer
{
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        string value = string.Empty;
        switch (property.propertyType)
        {
            case SerializedPropertyType.Generic:
                break;
            case SerializedPropertyType.Integer:
                value = property.intValue.ToString();
                break;
            case SerializedPropertyType.Boolean:
                break;
            case SerializedPropertyType.Float:
                break;
            case SerializedPropertyType.String:
                value = property.stringValue;
                break;
            case SerializedPropertyType.Color:
                value = property.colorValue.ToString();
                break;
            case SerializedPropertyType.ObjectReference:
                break;
            case SerializedPropertyType.LayerMask:
                break;
            case SerializedPropertyType.Enum:
                break;
            case SerializedPropertyType.Vector2:
                break;
            case SerializedPropertyType.Vector3:
                value = property.vector3Value.ToString();
                break;
            case SerializedPropertyType.Vector4:
                break;
            case SerializedPropertyType.Rect:
                value = property.rectValue.ToString();
                break;
            case SerializedPropertyType.ArraySize:
                break;
            case SerializedPropertyType.Character:
                break;
            case SerializedPropertyType.AnimationCurve:
                break;
            case SerializedPropertyType.Bounds:
                break;
            case SerializedPropertyType.Gradient:
                break;
            case SerializedPropertyType.Quaternion:
                break;
            case SerializedPropertyType.ExposedReference:
                break;
            case SerializedPropertyType.FixedBufferSize:
                break;
            case SerializedPropertyType.Vector2Int:
                break;
            case SerializedPropertyType.Vector3Int:
                break;
            case SerializedPropertyType.RectInt:
                break;
            case SerializedPropertyType.BoundsInt:
                break;
            default:
                throw new ArgumentOutOfRangeException();
                
        }
        //base.OnGUI(position, property, label);
        EditorGUI.LabelField(position, $"{property.name}\t\t:\t{value}");

        ReadOnlyAttribute attr = (ReadOnlyAttribute)attribute;
        Debug.Log(attribute.GetType().Name);
        GUI.color = attr.textColor;
        Debug.Log($"{property.name}:{attr.textColor}");
        GUI.color = Color.white;
      
        
    }

    public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
    {
        return base.GetPropertyHeight(property, label);
    }
}
